// 类型注解的定义  let 变量名: 变量类型名 = 变量值
let age: number = 10
age = 19
// age = "20"  //会报错，因为不允许为约定的类型赋给其他的值

// TSP常见类型
// JS原始类型
let num: number = 123
let str: string = "hello"
let bool: boolean = true
let und: undefined = undefined
let nul: null = null
// ES2020新加入
let sym: symbol = Symbol("123")
let bigInt: bigint = 123n

// 数组类型
let arr: number[] = [1, 2, 3, 4]
let number1: Array<number> =  [1, 2, 3, 4, 5]
let  testArray: Array<(boolean | number)> = [1, 2, true]
// console.log(arr, number1, testArray);

// 联合类型(typeA | typeB)
let arr1: (number | string)[] =  [1, 'a', 2, 'b']
let a1: (number | string) = 1
a1 = 2

// 类型别名 type  TestType = (number | string)[]
type  TestType = (number | string)[]
let arr2: TestType = [1, 2, '3', '4']

type AllType = (number | string | boolean | null | undefined | object)
let arr3: AllType[] = [1 , '1', false, null, undefined, {'array': 1}]
console.log(arr3);




// // 元组类型
// let tuple: [number, string] = [1, "hello"]

// // 枚举类型


